Denizen Script Language Explanations


Language Explanations explain components of Denizen in a more direct and technical way than The Beginner's Guide.


Showing 1 out of 85 language explanations...
NameItem Components
DescriptionMinecraft item components (see 🔗https://minecraft.wiki/w/Data_component_format) are managed as follows:
Each item type has a default set of component values; a food item will have food components by default, a tool item will have tool components by default, etc.
Different items can override their type's default components, either by setting values that weren't there previously (e.g. making an inedible item edible), or by removing values that are there by default (e.g. making a shield item that can't block).
Items' overrides can later be reset, making them use their type's default values again.

In Denizen, different item components are represented by item properties.
These properties allow both setting a component override on an item, and clearing/resetting it by providing no input.
Item properties' name will generally match their respective item component's name, but not always!
Due to this, features that take item component names as input (such as Tag:ItemTag.is_overridden) accept both Minecraft component names and Denizen property names.

Here is an example of applying all of this in a script:

# We define a default apple item
- define apple <item[apple]>
# We remove the apple's "food" component, making eating it restore no food points (it is still consumable due to the "consumable" component).
- adjust def:apple remove_component:food
# This check will pass, as the apple's "food" component is overridden to have no value.
- if <[apple].is_overridden[food]>:
  - narrate "The apple has a modified food component! It will behave differently to a normal apple."
# We reset the apple item's food component by adjusting with no value, making it a normal apple.
- adjust def:apple food:
GroupMinecraft Logic
Sourcehttps://github.com/DenizenScript/Denizen/blob/dev/paper/src/main/java/com/denizenscript/denizen/paper/datacomponents/DataComponentAdapter.java#L25